﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LSUtility;

namespace LSEntity
{
    [Serializable]
    public class TestOTCurrent
    {
        public TestClassEntity TestClassEntity { get; set; }
        public TestEntity TestEntity { get; set; }
        public List<QuestionType> QuestionTypeList { get; set; }
        public List<List<QuestionForOT>> QuestionForOTList { get; set; }
    }

    [Serializable]
    public class TestEntity
    {
        public int Id { get; set; }
        public TestCategory Creator { get; set; }
        public string CreatorText
        {
            get { return Creator.ObjGetDescription(); }
        }
        public Curriculum CurriculumId { get; set; }
        public int GredeId { get; set; }
        public int ModuleId { get; set; }
        public int UnitId { get; set; }
        public int AssignmentId { get; set; }
        public TestType TestType { get; set; }
        public DateTime CreateTime { get; set; }
        public string Name { get; set; }
        public string Password { get; set; }
        public TestClass TestClass { get; set; }
        public int IsRelease { get; set; }
        public int SchoolId { get; set; }
    }

    [Insert(Field = "test_class_mapping", Group = "insert")]
    [Insert(Field = "test_class_mapping", Group = "update", IsUpdate = true)]
    [Serializable]
    public class TestClassEntity
    {
        [Insert(Field = "ClassId", Group = "insert")]
        public int ClassId { get; set; }

        public string ClassName { get; set; }

        [Insert(Field = "TestId", Group = "insert")]
        public int TestId { get; set; }

        public string TestName { get; set; }

        [Insert(Field = "TestType", Group = "insert")]
        [Insert(Field = "TestType", Group = "update", IsUpdate = true)]
        public TestCategory TestType { get; set; }

        public string TestTypeTxt
        {
            get { return TestType.ObjGetDescription(); }
        }

        [Insert(Field = "BeginTime", Group = "insert")]
        [Insert(Field = "BeginTime", Group = "update", IsUpdate = true)]
        public DateTime BeginTime { get; set; }

        public DateTime EndTime
        {
            get { return BeginTime.AddMinutes(UserTime); }
        }

        public TestingStatus TestingStatus
        {
            get
            {
                if (BeginTime.ToShortDateString().Equals(DateTime.Now.ToShortDateString()))
                {
                    return TestingStatus.TestIng;
                }
                if (DateTime.Parse(BeginTime.ToShortDateString()) < DateTime.Parse(DateTime.Now.ToShortDateString()))
                {
                    return TestingStatus.Tested;
                }
                return TestingStatus.TestPre;
            }
        }

        public string TestStatusTxt
        {
            get { return TestingStatus.ObjGetDescription(); }
        }

        [Insert(Field = "UserTime", Group = "insert")]
        [Insert(Field = "UserTime", Group = "update", IsUpdate = true)]
        public int UserTime { get; set; }

        [Insert(Field = "PassWord", Group = "insert")]
        [Insert(Field = "PassWord", Group = "update", IsUpdate = true)]
        public string PassWord { get; set; }

        [Insert(Field = "CreatorId", Group = "insert")]
        [Insert(Field = "CreatorId", Group = "update", IsUpdate = true)]
        public int CreatorId { get; set; }

        public DateTime InTime { get; set; }
    }

    public class TestGetEntity
    {
        public int SchoolId { get; set; }
        public List<Curriculum> CurriculumId { get; set; }
        public int TestId { get; set; }
    }
}
